<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //数字转字符串
        let temp = 108;
        temp = temp.toString();
        document.write("数字转字符串后数据类型：" + typeof temp + "<br>");
        let str = "1145";
        str = Number(str);
        //字符串转数字
        document.write("字符串转数字后数据类型：" + typeof str + "<br>");
        let p = " ";
        document.write("空字符串或字符转数字：" + Number(p) + "<br>");
        document.write("非数字字符串转数字类型：" + Number("nfq") + "<br><hr>");
        //true是1  false是0
        document.write("非0数字转布尔类型：" + Boolean(123) + "<br>");
        document.write("空字符串转布尔类型：" + Boolean("") + "<br>");
        document.write("数字0转布尔类型：" + Boolean(0) + "<br>");
        document.write("字符串0转布尔类型：" + Boolean("0") + "<br><hr>");
        //数组转字符串
        var months = ["Jan", "Feb", "Mar", "Apr", "May"];
        document.write("原数组：" + months + "<br>");
        document.write("数组转字符串：" + months.toString() + "<br>");
        document.write("数组转字符串(中间用+分割 用join)：" + months.join(" + ") + "<br><hr>");
        //字符串转数组
        var s = 'Air Pollution is introduction of chemicals to the atmosphere.';
        var arr = s.split(" ");
        var arr2 = s.split("");
        document.write("原字符串：" + s + "<br>");
        document.write("字符串转数组(空格分割)" + arr + "<br>")
        document.write("字符串转数组(空字符串分割)" + arr2 + "<br><hr>")
    </script>
</body>

</html>